package com.jp.knowledge.my.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jp.knowledge.R;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.my.model.VipModel;
import com.jp.knowledge.util.ImageLoadUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/5/8.
 */

public class EnterpriseVipAdapter extends UserVipAdapter {

    public EnterpriseVipAdapter(Context context, @NonNull List<VipModel> list) {
        super(context, list);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_enterprise_vip;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        VipModel data = getData(position);
        List<VipModel.ListBean> listBean = data.getList();
        if(listBean == null)
            listBean = new ArrayList<>();
        for(int i = listBean.size(); i < 4; i++)
            listBean.add(new VipModel.ListBean());

        TextView serviceTv = holder.getTextView(R.id.service_tv);
        ImageView serviceIv = holder.getImageView(R.id.service_iv);
        TextView normalTv = holder.getTextView(R.id.normal_tv);
        ImageView normalIv = holder.getImageView(R.id.normal_iv);
        TextView silverVipTv = holder.getTextView(R.id.silver_vip_tv);
        ImageView silverVipIv = holder.getImageView(R.id.silver_vip_iv);
        TextView goldVipTv = holder.getTextView(R.id.gold_vip_tv);
        ImageView goldVipIv = holder.getImageView(R.id.gold_vip_iv);
        TextView drillVipTv = holder.getTextView(R.id.drill_vip_tv);
        ImageView drillVipIv = holder.getImageView(R.id.drill_vip_iv);

        setItemView(serviceTv, data.getTitle(), data.getColor(), serviceIv, data.getIcon());
        VipModel.ListBean normalBean = listBean.get(0);
        setItemView(normalTv, normalBean.getInfo(), normalBean.getColor(), normalIv, normalBean.getIcon());
        VipModel.ListBean silverVipBean = listBean.get(1);
        setItemView(silverVipTv, silverVipBean.getInfo(), silverVipBean.getColor(), silverVipIv, silverVipBean.getIcon());
        VipModel.ListBean goldBean = listBean.get(2);
        setItemView(goldVipTv, goldBean.getInfo(), goldBean.getColor(), goldVipIv, goldBean.getIcon());
        VipModel.ListBean drillVipBean = listBean.get(3);
        setItemView(drillVipTv, drillVipBean.getInfo(), drillVipBean.getColor(), drillVipIv, drillVipBean.getIcon());
    }
}
